<template>
    <el-card class="item">
        <template #header>
            <div class="card-header">
                <span>土壤湿度</span>
            </div>
        </template>
        <div id="soil" ref="isMounted" style="width: 100%;height: 250px;">
        </div>
    </el-card>
</template>
<script setup>
import { ref,watchEffect } from 'vue'
import * as echarts from 'echarts'
const isMounted = ref(null);
const props = defineProps({
    soil:Array
})
const draw = () => {
    var chartDom = document.getElementById('soil');
    var myChart = echarts.init(chartDom);
    var option;
    option = {
        xAxis: {
            type: 'category',
            data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
        },
        yAxis: {
            type: 'value'
        },
        series: [
            {
                data: props.soil,
                type: 'line'
            }
        ]
    };
    option && myChart.setOption(option);
}
watchEffect(()=>{
    if(isMounted.value){
        draw()
    }
})
</script>
